time = [1
1.2
1.3
1.5
1.6
1.8
2];

temperature = [ 80.5 71.1 76.7
83.3 73.9 78.9
88.9 80 83.9
94.4 86.1 85.6
96.7 90 82.3
97.2 92.2 96.1
100 98.9 105];

//vandermonde = [ 1 1 1
//1 1.2 1.44
//1 1.3 1.69
//1 1.5 2.25
// 1.6 2.56
//1 1.8 3.24
//1 2 4];

//this returns 59
//temperature = [80.5
//83.3
//88.9
//94.4
//96.7
//97.2
//100];

//2011
//returns [59.78 55.67 57.08], the best fit. how? these are all off by about 20 degrees? which would make the polynomial
//for the curve 59.78 + 55.67t + 57.08^2

//with the use of the vandermonde matrix, X becomes a 3x3
//X = lsq(time,temperature);    //returns 59,55,57
X = lsq(temperature,time);
//X1 = vandermonde\temperature;
//X2 = temperature\vandermonde;
//X1 = time\temperature;    //returns 59, 55, 57

for i=1:7
    //eqn from p. 108
    //y =   172.52843  
    //208.7758   
    //228.6118   
    //271.70844  
    //294.96907  
    //344.91498  
    //399.42707
    //    59    +    55(1)        + 57*(1) = y1
   y(i)= (X(1,1)*time(i)) + (X(2,1)*time(i)) + (X(3,1)*(time(i)^2));
   //y1 = X +X*time(i)+X*time(i)^2 ;
   //y(i)= X(1,1) + (X(1,2)*time(i)) + (X(1,3)*(time(i)^2));
end
//plot(y,time, '*')
plot(time,y,'*')


//This is the dotplot of the values. 
title('Hot Pocket Data');
xlabel('temp(C)');
ylabel('time(m)');
//plot(temperature,time)
plot(time,temperature)

